package com.sian.audit.action;

import java.util.List;
import java.util.HashMap;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.logging.Log;
import javax.servlet.http.HttpSession;
import org.apache.commons.logging.LogFactory;
import org.springframework.http.HttpStatus;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import com.sian.audit.service.AuditService;

@Controller
@RequestMapping("/audit")
public class AuditAction {
	@Resource
	private AuditService service;

	@RequestMapping(value = "index")
	public String forwardauditIndexJsp(HttpServletRequest request,
			HttpSession session) throws Exception {
		return "audit/index";
	}

	@RequestMapping(value = "grid", method = RequestMethod.POST)
	public String forwardauditGrid(int page, int rows,
			HttpServletRequest request) throws Exception {
		
		HashMap<String, Object> params = new HashMap<String, Object>();
		//params.put("page", pageInfo);
		List<com.sian.audit.pojo.auditPojo> audit_list = service
				.getauditByPage(params);
		request.setAttribute("audit_list", audit_list);
		//request.setAttribute("pageInfo", pageInfo);
		return "audit/grid";
	}

	@RequestMapping(value = "forwordEdit")
	public String forwardEditJsp(HttpServletRequest request, HttpSession session)
			throws Exception {
		String id_str = request.getParameter("id");
		if (id_str != null && (id_str.length()) > 0
				&& (!id_str.trim().equals("undefined"))) {
			com.sian.audit.pojo.auditPojo pojo_model = service
					.getauditById(id_str);
			request.setAttribute("audit_obj", pojo_model);
		}
		return "audit/edit";
	}

	@RequestMapping(value = "saveupdate", method = RequestMethod.POST)
	@ResponseStatus(value = HttpStatus.OK)
	public void saveOrupdateaudit(HttpServletRequest request,
			HttpSession session) throws Exception {
	}

	@RequestMapping(value = "delete", method = RequestMethod.POST)
	@ResponseStatus(value = HttpStatus.OK)
	public void deleteaudit(HttpServletRequest request, String id)
			throws Exception {
		service.deleteaudit(id);
	}
}